package com.smart.village.big.screen.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.smart.village.big.screen.domain.Comments;
import com.smart.village.big.screen.domain.NewsVo;
import com.smart.village.big.screen.mapper.CommentsMapper;
import com.smart.village.big.screen.mapper.MicroSmartMoHeTouristMapper;
import com.smart.village.big.screen.service.MicroSmartMoHeTouristService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;

import java.util.*;

@Service
public class MicroSmartMoHeTouristServiceImpl implements MicroSmartMoHeTouristService {
    @Autowired
    private MicroSmartMoHeTouristMapper microSmartMoHeTouristMapper;
    @Autowired
    private CommentsMapper commentsMapper;

    @Value("${mohe.tourist.complaint.governance}")
    private String moheTouristComplaintGovernance;

    @Override
    public JSONObject getHotelApartmentsSearch(String search, String category, String address,
                                               String merchantName, String shopName,
                                               String orderCondition, String orderType, String currentCoords,
                                               String distanceParam,
                                               String beginPrice,
                                               String endPrice, String villageNumber,
                                               String filterSearchJson,
                                               int pageNum, int pageSize) throws Exception {
        PageHelper.startPage(pageNum, pageSize);

        List<JSONObject> filterSearchArray = new ArrayList<>();
        if (StringUtils.isNotEmpty(filterSearchJson)) {
            filterSearchArray = JSON.parseArray(filterSearchJson, JSONObject.class);
        }

        List<JSONObject> list = microSmartMoHeTouristMapper.getHotelApartmentsSearch(search, category, address, merchantName, shopName, orderCondition, orderType, currentCoords,
                distanceParam,
                beginPrice,
                endPrice, villageNumber, filterSearchArray);
        for (JSONObject jsonObject : list) {
            Set<String> categoryList = Sets.newConcurrentHashSet();
            if (null != (jsonObject.get("Room_Type_SerialNumber"))) {
                String Room_Type_SerialNumber = jsonObject.get("Room_Type_SerialNumber").toString();
                String[] roomTypeSerialNumberArray = Room_Type_SerialNumber.split(",");
                for (String roomTypeSerialNumber : roomTypeSerialNumberArray) {
                    // 据据room type 获取 category 然后 再根据category的称称 标注到每个店铺上
                    JSONObject hotelApartmentRoomTypeDetail = microSmartMoHeTouristMapper.getHotelApartmentRoomTypeDetail(roomTypeSerialNumber);
                    if (null != hotelApartmentRoomTypeDetail) {
                        if (null != hotelApartmentRoomTypeDetail.get("Room_Category_SerialNumber")) {
                            String[] roomCategorySerialNumbers = hotelApartmentRoomTypeDetail.getString("Room_Category_SerialNumber").split(",");
                            for (String roomCategorySerialNumber : roomCategorySerialNumbers) {
                                JSONObject roomCategorySerialNumberDetail = microSmartMoHeTouristMapper.getRoomCategorySerialNumberDetail(roomCategorySerialNumber);
                                if (null != roomCategorySerialNumberDetail) {
                                    categoryList.add(roomCategorySerialNumberDetail.getString("Room_Category"));
                                }
                            }
                        }
                    }
                }
            }
            jsonObject.put("Category_List", categoryList);

            String Merchant_Alias_Type = "";
            Object o = jsonObject.get("Merchant_Alias_Type_SerialNumber");
            if (null != o && !Objects.equals(o.toString(), "")) {
                String[] aliasTypeSerialNumber = jsonObject.getString("Merchant_Alias_Type_SerialNumber").split(",");
                for (Object merchantAliasTypeSerialNumber1 : aliasTypeSerialNumber) {
                    JSONObject merchantAliasTypeSerialNumberDetail = microSmartMoHeTouristMapper.getMerchantAliasTypeSerialNumberDetail(merchantAliasTypeSerialNumber1.toString());
                    if (null != merchantAliasTypeSerialNumberDetail) {
                        Merchant_Alias_Type += (merchantAliasTypeSerialNumberDetail.getString("Merchant_Alias_Type") + ",");
                    }
                }
            }
            jsonObject.put("Merchant_Alias_Type", StringUtils.isEmpty(Merchant_Alias_Type) ? "" : Merchant_Alias_Type.substring(0, Merchant_Alias_Type.length() - 1));

        }
        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
        JSONObject result = new JSONObject();
        result.put("list", pageInfo.getList());
        result.put("total", pageInfo.getTotal());
        return result;
    }

    @Override
    public JSONObject getHotelApartmentShopDetail(String shopSerialNumber, String currentCoords) {

        JSONObject hotelApartmentShopDetail = microSmartMoHeTouristMapper.getHotelApartmentShopDetail(shopSerialNumber, currentCoords);
        if (null != hotelApartmentShopDetail && !Objects.equals(hotelApartmentShopDetail.toString(), "")) {
            String[] aliasTypeSerialNumber = hotelApartmentShopDetail.getString("Merchant_Alias_Type_SerialNumber").split(",");
            List<String> aliasList = Lists.newArrayList();

            for (Object merchantAliasTypeSerialNumber1 : aliasTypeSerialNumber) {
                JSONObject merchantAliasTypeSerialNumberDetail = microSmartMoHeTouristMapper.getMerchantAliasTypeSerialNumberDetail(merchantAliasTypeSerialNumber1.toString());
                if (null != merchantAliasTypeSerialNumberDetail) {
                    aliasList.add(merchantAliasTypeSerialNumberDetail.getString("Merchant_Alias_Type"));
                }
            }
            hotelApartmentShopDetail.put("Alias_List", aliasList);
        }
        JSONObject viewDomain = microSmartMoHeTouristMapper.getViewDomain(shopSerialNumber, hotelApartmentShopDetail.getString("Merchant_Category"));
        if (null != viewDomain) {
            microSmartMoHeTouristMapper.addViewCntDomain(viewDomain.getString("id"));
        } else {
            String domainId = shopSerialNumber;
            String type = hotelApartmentShopDetail.getString("Merchant_Category");
            microSmartMoHeTouristMapper.addViewDomain(domainId, type);
        }
        List<JSONObject> hotelApartmentRoomTypeList = microSmartMoHeTouristMapper.getHotelApartmentRoomTypeList(hotelApartmentShopDetail.getString("Merchant_Mapping_Blue_Plate_SerialNumber"));
        hotelApartmentShopDetail.put("roomTypeList", hotelApartmentRoomTypeList);

        List<JSONObject> merchant_alias_image = microSmartMoHeTouristMapper.getMerchantAliasImage(shopSerialNumber);
        hotelApartmentShopDetail.put("Merchant_Alias_Image", merchant_alias_image);

        return hotelApartmentShopDetail;
    }

    @Override
    public JSONObject getHotelApartmentRoomTypeDetail(String typeSerialNumber) {
        JSONObject hotelApartmentRoomTypeDetail = microSmartMoHeTouristMapper.getHotelApartmentRoomTypeDetail(typeSerialNumber);


        List<JSONObject> hotelApartmentRoomTypeImageList = microSmartMoHeTouristMapper.getHotelApartmentRoomTypeImageList(typeSerialNumber);
        hotelApartmentRoomTypeDetail.put("imageList", hotelApartmentRoomTypeImageList);
        List<JSONObject> icoList = Lists.newArrayList();


        Object o2 = hotelApartmentRoomTypeDetail.get("Room_Area_Size");
        Object o3 = hotelApartmentRoomTypeDetail.get("Room_Layer");
        Object o4 = hotelApartmentRoomTypeDetail.get("Window_Type_SerialNumber");
        Object o5 = hotelApartmentRoomTypeDetail.get("Is_Wifi");
        Object o6 = hotelApartmentRoomTypeDetail.get("Is_Partial_Smoking_Ban");
        Object o7 = hotelApartmentRoomTypeDetail.get("Max_Occupancy");
        Object o8 = hotelApartmentRoomTypeDetail.get("Is_Breakfast");

        JSONObject icon1 = new JSONObject();
        icon1.put("src", "roomInformation-1.png");
        Object o1 = hotelApartmentRoomTypeDetail.get("Bed_Config");
        if (null != o1) {
            icon1.put("title", o1.toString());
            icoList.add(icon1);
        }
        JSONObject icon2 = new JSONObject();
        icon2.put("src", "roomInformation-2.png");
        if (null != o2) {
            icon2.put("title", o2.toString());
            icoList.add(icon2);

        }
        JSONObject icon3 = new JSONObject();
        icon3.put("src", "roomInformation-3.png");
        if (null != o3) {
            icon3.put("title", o3.toString() + "层");
            icoList.add(icon3);

        }
        JSONObject icon4 = new JSONObject();
        icon4.put("src", "roomInformation-4.png");
        if (null != o4) {
            switch (o4.toString()) {
                case "1":
                    icon4.put("title", "有窗");
                    break;
                case "2":
                    icon4.put("title", "无窗");
                    break;
                case "3":
                    icon4.put("title", "落地");
                    break;
            }
            icoList.add(icon4);

        }
        JSONObject icon5 = new JSONObject();
        icon5.put("src", "roomInformation-5.png");
        if (null != o5) {
            switch (o5.toString()) {
                case "1":
                    icon5.put("title", "有");
                    break;
                case "0":
                    icon5.put("title", "无");
                    break;
            }

            icoList.add(icon5);

        }
        JSONObject icon6 = new JSONObject();
        icon6.put("src", "roomInformation-6.png");
        if (null != o6) {
            switch (o6.toString()) {
                case "1":
                    icon6.put("title", "有");
                    break;
                case "0":
                    icon6.put("title", "无");
                    break;
            }
            icoList.add(icon6);

        }
        JSONObject icon7 = new JSONObject();
        icon7.put("src", "roomInformation-7.png");
        if (null != o7) {

            icon7.put("title", o7.toString() + "人");
            icoList.add(icon7);

        }
        JSONObject icon8 = new JSONObject();
        icon8.put("src", "roomInformation-8.png");
        if (null != o8) {
            switch (o8.toString()) {
                case "1":
                    icon8.put("title", "有");
                    break;
                case "0":
                    icon8.put("title", "无");
                    break;
            }
            icoList.add(icon8);
        }


        hotelApartmentRoomTypeDetail.put("icoList", icoList);
        return hotelApartmentRoomTypeDetail;
    }

    @Override
    public JSONObject getScenicSpotList(String currentCoords, String scenicSpotTagSerialNumber, String search, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<JSONObject> list = microSmartMoHeTouristMapper.getScenicSpotList(currentCoords, scenicSpotTagSerialNumber, search);
        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
        JSONObject result = new JSONObject();
        result.put("list", pageInfo.getList());
        result.put("total", pageInfo.getTotal());
        return result;
    }

    @Override
    public JSONObject getScenicSpotDetail(String scenicSpotSerialNumber) {
        JSONObject viewDomain = microSmartMoHeTouristMapper.getViewDomain(scenicSpotSerialNumber, "景区");
        if (null != viewDomain) {
            microSmartMoHeTouristMapper.addViewCntDomain(viewDomain.getString("id"));
        } else {
            String domainId = scenicSpotSerialNumber;
            String type = "景区";
            microSmartMoHeTouristMapper.addViewDomain(domainId, type);
        }
        JSONObject scenicSpotDetail = microSmartMoHeTouristMapper.getScenicSpotDetail(scenicSpotSerialNumber);
        if(ObjectUtils.isEmpty(scenicSpotDetail)) {
            return new JSONObject();
        }
        List<String> ChildCoverList = Lists.newArrayList();
        List<JSONObject> scenicSpotDetailChlidlList = microSmartMoHeTouristMapper.getScenicSpotDetailChlidlList(scenicSpotSerialNumber);
        for (JSONObject jsonObject : scenicSpotDetailChlidlList) {
            List<JSONObject> scenicSpotDetailImageList = microSmartMoHeTouristMapper.getScenicSpotImageList(jsonObject.getString("Scenic_Spot_Detail_SerialNumber"));
            jsonObject.put("Image_List", scenicSpotDetailImageList);
            ChildCoverList.add(jsonObject.getString("Picture_URL"));
        }
        ChildCoverList.add(StringUtils.isEmpty(scenicSpotDetail.getString("Picture_URL")) ? "" : scenicSpotDetail.getString("Picture_URL"));
        scenicSpotDetail.put("ChildCoverList", ChildCoverList);
        scenicSpotDetail.put("Introduction", scenicSpotDetailChlidlList);

        List<JSONObject> dailyTicketInfo = microSmartMoHeTouristMapper.getStaticImportentTourScencePrice(scenicSpotSerialNumber);
        scenicSpotDetail.put("dailyTicketInfo", dailyTicketInfo);
        return scenicSpotDetail;
    }

    @Override
    public JSONObject getTouristRouteList(String touristRouteType, String search, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<JSONObject> list = microSmartMoHeTouristMapper.getTouristRouteList(touristRouteType, search);
        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
        JSONObject result = new JSONObject();
        result.put("list", pageInfo.getList());
        result.put("total", pageInfo.getTotal());
        return result;
    }

    @Override
    public JSONObject getTouristRouteDetail(String touristRouteSerialNumber) {
        JSONObject touristRouteDetail = microSmartMoHeTouristMapper.getTouristRouteDetail(touristRouteSerialNumber);

        microSmartMoHeTouristMapper.updateTouristRouteViewCount(touristRouteSerialNumber);
        List<JSONObject> touristRouteDetailChlidlList = microSmartMoHeTouristMapper.getTouristRouteDetailChlidlList(touristRouteSerialNumber);

        touristRouteDetail.put("Introduction", touristRouteDetailChlidlList);
        return touristRouteDetail;
    }

    @Override
    public JSONObject getDeliciousFoodSearch(String address, String merchantName, String shopName, String orderCondition, String orderType,
                                             String currentCoords, String merchantAliasTypeSerialNumber,
                                             String distanceParam,
                                             String beginPrice,
                                             String endPrice,
                                             int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        String[] merchantAliasTypeSplit = null;
        if (StringUtils.isNotEmpty(merchantAliasTypeSerialNumber)) {
            merchantAliasTypeSplit = merchantAliasTypeSerialNumber.split(",");
        }

        List<JSONObject> list = microSmartMoHeTouristMapper.getDeliciousFoodSearch(address, merchantName, shopName, orderCondition, orderType, currentCoords, merchantAliasTypeSplit, distanceParam, beginPrice, endPrice);
        for (JSONObject jsonObject : list) {
            List<String> aliasList = Lists.newArrayList();
            Object o = jsonObject.get("Merchant_Alias_Type_SerialNumber");
            if (null != o && !Objects.equals(o.toString(), "")) {
                String[] aliasTypeSerialNumber = jsonObject.getString("Merchant_Alias_Type_SerialNumber").split(",");
                for (Object merchantAliasTypeSerialNumber1 : aliasTypeSerialNumber) {
                    JSONObject merchantAliasTypeSerialNumberDetail = microSmartMoHeTouristMapper.getMerchantAliasTypeSerialNumberDetail(merchantAliasTypeSerialNumber1.toString());
                    if (null != merchantAliasTypeSerialNumberDetail) {
                        aliasList.add(merchantAliasTypeSerialNumberDetail.getString("Merchant_Alias_Type"));
                    }
                }
            }
            jsonObject.put("Alias_List", aliasList);
        }
        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
        JSONObject result = new JSONObject();
        result.put("list", pageInfo.getList());
        result.put("total", pageInfo.getTotal());
        return result;
    }

    @Override
    public JSONObject getSuperMarkerSearch(String search, String address, String merchantName, String shopName, String orderCondition, String orderType, String currentCoords, String merchantAliasTypeSerialNumber, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<JSONObject> list = microSmartMoHeTouristMapper.getSuperMarkerSearch(search, address, merchantName, shopName, orderCondition, orderType, currentCoords, merchantAliasTypeSerialNumber);
        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
        JSONObject result = new JSONObject();
        result.put("list", pageInfo.getList());
        result.put("total", pageInfo.getTotal());
        return result;
    }

    @Override
    public JSONObject getDeliciousFoodShopDetail(String shopSerialNumber, String currentCoords) {
        JSONObject deliciousFoodShopDetail = microSmartMoHeTouristMapper.getDeliciousFoodShopDetail(shopSerialNumber, currentCoords);
        if (null != deliciousFoodShopDetail && !Objects.equals(deliciousFoodShopDetail.toString(), "")) {
            String[] aliasTypeSerialNumber = deliciousFoodShopDetail.getString("Merchant_Alias_Type_SerialNumber").split(",");
            List<String> aliasList = Lists.newArrayList();

            for (Object merchantAliasTypeSerialNumber1 : aliasTypeSerialNumber) {
                JSONObject merchantAliasTypeSerialNumberDetail = microSmartMoHeTouristMapper.getMerchantAliasTypeSerialNumberDetail(merchantAliasTypeSerialNumber1.toString());
                if (null != merchantAliasTypeSerialNumberDetail) {
                    aliasList.add(merchantAliasTypeSerialNumberDetail.getString("Merchant_Alias_Type"));
                }
            }
            deliciousFoodShopDetail.put("Alias_List", aliasList);
        }
        List<JSONObject> dishInfoList = microSmartMoHeTouristMapper.getDishInfoList(shopSerialNumber);
        deliciousFoodShopDetail.put("Dish_Info_List", dishInfoList);
        return deliciousFoodShopDetail;
    }

    @Override
    public JSONObject getSuperMarkerShopDetail(String shopSerialNumber, String currentCoords) {
        JSONObject superMarkerShopDetail = microSmartMoHeTouristMapper.getSuperMarkerShopDetail(shopSerialNumber, currentCoords);
        List<JSONObject> agriculturalGoodsList = microSmartMoHeTouristMapper.getAgriculturalGoodsList(shopSerialNumber);
        superMarkerShopDetail.put("Agricultural_Goods_List", agriculturalGoodsList);
        return superMarkerShopDetail;
    }


    @Override
    public JSONObject getShopDetailComments(String commentObjectSerialNumber, String commentType, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Comments> comments = commentsMapper.getShopDetailComments(commentObjectSerialNumber, commentType);
        comments.forEach(comment -> {
            comment.setAttachmentList(commentsMapper.getShopDetailCommentsAttachList(comment.getCommentSerialNumber()));
        });
        PageInfo<Comments> pageInfo = new PageInfo<>(comments);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list", pageInfo.getList());
        jsonObject.put("total", pageInfo.getTotal());
        return jsonObject;
    }

    @Override
    public JSONObject getAgriculturalGoodsSearch(String agriculturalSuppliesStoreGoodsTypeSerialNumber, String goodsName, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        String[] split = {};
        if (StringUtils.isNotEmpty(agriculturalSuppliesStoreGoodsTypeSerialNumber)) {
            split = agriculturalSuppliesStoreGoodsTypeSerialNumber.split(",");
        }
        List<JSONObject> list = microSmartMoHeTouristMapper.getAgriculturalGoodsSearch(split, goodsName);
        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
        JSONObject result = new JSONObject();
        result.put("list", pageInfo.getList());
        result.put("total", pageInfo.getTotal());
        return result;
    }


    @Override
    public JSONObject getAgriculturalGoodsDetail(String agriculturalSuppliesStoreGoodsSerialNumber, String currentCoords) {
        JSONObject agriculturalGoodsDetail = microSmartMoHeTouristMapper.getAgriculturalGoodsDetail(agriculturalSuppliesStoreGoodsSerialNumber);
        JSONObject viewDomain = microSmartMoHeTouristMapper.getViewDomain(agriculturalGoodsDetail.getString("Agricultural_Supplies_Store_Goods_SerialNumber"), "农产品");
        if (null != viewDomain) {
            microSmartMoHeTouristMapper.addViewCntDomain(viewDomain.getString("id"));
        } else {
            String domainId = agriculturalGoodsDetail.getString("Agricultural_Supplies_Store_Goods_SerialNumber");
            String type = "农产品";
            microSmartMoHeTouristMapper.addViewDomain(domainId, type);
        }
        List<JSONObject> agriculturalGoodsImages = microSmartMoHeTouristMapper.getAgriculturalGoodsImages(agriculturalSuppliesStoreGoodsSerialNumber);
        if (!CollectionUtils.isEmpty(agriculturalGoodsImages)) {
            agriculturalGoodsImages.forEach(jsonObject1 -> {
                if (jsonObject1.getString("Image_Type").equals("C")) {
                    jsonObject1.put("Image_Type_Name", "封面");
                }
                if (jsonObject1.getString("Image_Type").equals("M")) {
                    jsonObject1.put("Image_Type_Name", "主图");
                }
                if (jsonObject1.getString("Image_Type").equals("D")) {
                    jsonObject1.put("Image_Type_Name", "明细图");
                }
            });
        }
        agriculturalGoodsDetail.put("Image_List", agriculturalGoodsImages);
        List<JSONObject> agriculturalGoodsShopList = microSmartMoHeTouristMapper.getAgriculturalGoodsShopList(agriculturalGoodsDetail.getString("Agricultural_Supplies_Store_Goods_SerialNumber"), currentCoords);
        agriculturalGoodsDetail.put("Shop_List", agriculturalGoodsShopList);
        return agriculturalGoodsDetail;
    }

    @Override
    public JSONObject getMyBookRoomList(String phone, String status, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        String[] split = {};
        if (StringUtils.isNotEmpty(status)) {
            split = status.split(",");
        }
        List<JSONObject> list = microSmartMoHeTouristMapper.getMyBookRoomList(phone, split);
        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
        JSONObject result = new JSONObject();
        result.put("list", pageInfo.getList());
        result.put("total", pageInfo.getTotal());
        return result;
    }

    @Override
    public JSONObject getMyShopComments(String phone, String type, String shopType, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        String shopParentCategorySerialNumber = null;
        if (StringUtils.isEmpty(shopType)) {
            shopParentCategorySerialNumber = null;
        } else {
            if (shopType.equals("商超")) {
                shopParentCategorySerialNumber = "MC0000000000012";
            }
            if (shopType.equals("美食")) {
                shopParentCategorySerialNumber = "MC0000000000011";
            }
            if (shopType.equals("酒店民宿")) {
                shopParentCategorySerialNumber = "MC0000000000013";
            }
        }
        List<JSONObject> list = microSmartMoHeTouristMapper.getMyShopFirstComments(phone, type, shopParentCategorySerialNumber);
        for (JSONObject jsonObject : list) {
            List<JSONObject> myShopCommentsReplyMe = microSmartMoHeTouristMapper.getMyShopCommentsReplyMe(jsonObject.getString("Comment_SerialNumber"), type);
            jsonObject.put("Reply_List", myShopCommentsReplyMe);
        }
        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
        JSONObject result = new JSONObject();
        result.put("list", pageInfo.getList());
        result.put("total", pageInfo.getTotal());
        return result;
    }

    @Override
    public JSONObject getMyComplaints(String phone, String status, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        if (StringUtils.isNotEmpty(status)) {
            if (status.equals("待处理")) {
                status = "提交";
            }
            if (status.equals("处理中")) {
                status = "处理";
            }
        }
        List<JSONObject> list = microSmartMoHeTouristMapper.getMyComplaints(phone, status);
        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
        JSONObject result = new JSONObject();
        result.put("list", pageInfo.getList());
        result.put("total", pageInfo.getTotal());
        return result;
    }

    @Override
    public JSONObject getMyComplaintsDetail(String complaintId) {
        JSONObject myComplaintsDetail = microSmartMoHeTouristMapper.getMyComplaintsDetail(complaintId);
        return myComplaintsDetail;
    }

    @Override
    public JSONObject getMyBookRoomDetail(String roomTypeBookingsSerialNumber,String phone) {
        JSONObject myBookRoomDetail = microSmartMoHeTouristMapper.getMyBookRoomDetail(roomTypeBookingsSerialNumber,phone);
        List<JSONObject> bookDishList = microSmartMoHeTouristMapper.getMyBookDishListByRoomTypeBookingsSerialNumber(roomTypeBookingsSerialNumber);
        myBookRoomDetail.put("Book_Dish_List", bookDishList);
        return myBookRoomDetail;
    }

    @Override
    public JSONObject getNoticePublish(int pageNum, int pageSize, int i, String NewsTerminal) {
        PageHelper.startPage(pageNum, pageSize);
        List<NewsVo> list = microSmartMoHeTouristMapper.getNoticePublish(i, NewsTerminal);
        execFormatSubTitle(list);
        PageInfo<NewsVo> pageInfo = new PageInfo<>(list);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list", pageInfo.getList());
        jsonObject.put("total", pageInfo.getTotal());
        return jsonObject;
    }

    @Override
    public JSONObject getScenicSpotStrategy(String scenicSpotSerialNumber, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<JSONObject> list = microSmartMoHeTouristMapper.getScenicSpotStrategy(scenicSpotSerialNumber);
        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
        JSONObject result = new JSONObject();
        result.put("list", pageInfo.getList());
        result.put("total", pageInfo.getTotal());
        return result;
    }

    @Override
    public List<JSONObject> getScenicSpotAllTagList() {
        return microSmartMoHeTouristMapper.getScenicSpotAllTagList();
    }

    @Override
    public List<JSONObject> getMerchantAliasTypeAllList() {
        List<JSONObject> list = microSmartMoHeTouristMapper.getMerchantAliasTypeAllList();
        Set<String> aliasTypeList = new HashSet<>();
        for (JSONObject jsonObject : list) {
            String[] split = jsonObject.getString("Merchant_Alias_Type_SerialNumber").split(",");
            for (String s : split) {
                aliasTypeList.add(s);
            }
        }
        List<JSONObject> result = new ArrayList<>();
        for (String s : aliasTypeList) {
            JSONObject jsonObject = microSmartMoHeTouristMapper.getMerchantAliasTypeDetail(s);
            result.add(jsonObject);
        }
        return result;
    }

    @Override
    public List<JSONObject> getTouristRouteAllTypeList() {
        return microSmartMoHeTouristMapper.getTouristRouteAllTypeList();
    }

    @Override
    public JSONObject getScenicSpotStrategyDetail(String scenicSpotStrategySerialNumber) {
        microSmartMoHeTouristMapper.updateScenicSpotStrategyViewCount(scenicSpotStrategySerialNumber);
        return microSmartMoHeTouristMapper.getScenicSpotStrategyDetail(scenicSpotStrategySerialNumber);
    }

    @Override
    public List<JSONObject> getCarouselConfig() {
        return microSmartMoHeTouristMapper.getCarouselConfig();
    }

    @Override
    public List<JSONObject> getSuperMarkerTypeAllList() {
        List<JSONObject> list = microSmartMoHeTouristMapper.getSuperMarkerTypeAllList();
        Set<String> aliasTypeList = new HashSet<>();
        for (JSONObject jsonObject : list) {
            String[] split = jsonObject.getString("Merchant_Alias_Type_SerialNumber").split(",");
            for (String s : split) {
                aliasTypeList.add(s);
            }
        }
        List<JSONObject> result = new ArrayList<>();
        for (String s : aliasTypeList) {
            JSONObject jsonObject = microSmartMoHeTouristMapper.getMerchantAliasTypeDetail(s);
            result.add(jsonObject);
        }
        return result;
    }

    @Override
    public JSONObject getShopSearch(String search, String address, String merchantName, String shopName, String orderCondition, String orderType, String currentCoords, String merchantAliasTypeSerialNumber, String distanceParam, String beginPrice, String endPrice, String shopType, String villageNumber, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        String[] merchantAliasTypeSplit = null;
        if (StringUtils.isNotEmpty(merchantAliasTypeSerialNumber)) {
            merchantAliasTypeSplit = merchantAliasTypeSerialNumber.split(",");
        }

        String shopParentCategorySerialNumber = null;
        if (StringUtils.isEmpty(shopType)) {
            shopParentCategorySerialNumber = "MC0000000000011";
        }
        if (shopType.equals("商超")) {
            shopParentCategorySerialNumber = "MC0000000000012";
        }
        if (shopType.equals("美食")) {
            shopParentCategorySerialNumber = "MC0000000000011";
        }

        List<JSONObject> list = microSmartMoHeTouristMapper.getShopSearch(search, address, merchantName, shopName, orderCondition, orderType, currentCoords, merchantAliasTypeSplit, distanceParam, beginPrice, endPrice, shopParentCategorySerialNumber, villageNumber);
        for (JSONObject jsonObject : list) {
            List<String> aliasList = Lists.newArrayList();
            Object o = jsonObject.get("Merchant_Alias_Type_SerialNumber");
            if (null != o && !Objects.equals(o.toString(), "")) {
                String[] aliasTypeSerialNumber = jsonObject.getString("Merchant_Alias_Type_SerialNumber").split(",");
                for (Object merchantAliasTypeSerialNumber1 : aliasTypeSerialNumber) {
                    JSONObject merchantAliasTypeSerialNumberDetail = microSmartMoHeTouristMapper.getMerchantAliasTypeSerialNumberDetail(merchantAliasTypeSerialNumber1.toString());
                    if (null != merchantAliasTypeSerialNumberDetail) {
                        aliasList.add(merchantAliasTypeSerialNumberDetail.getString("Merchant_Alias_Type"));
                    }
                }
            }
            jsonObject.put("Alias_List", aliasList);
            jsonObject.put("ShopType", shopType);
        }
        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
        JSONObject result = new JSONObject();
        result.put("list", pageInfo.getList());
        result.put("total", pageInfo.getTotal());
        return result;
    }

    @Override
    public JSONObject getShopDetail(String shopSerialNumber, String currentCoords, String shopType) {

        if (shopType.equals("商超")) {
            JSONObject viewDomain = microSmartMoHeTouristMapper.getViewDomain(shopSerialNumber, shopType);
            if (null != viewDomain) {
                microSmartMoHeTouristMapper.addViewCntDomain(viewDomain.getString("id"));
            } else {
                String domainId = shopSerialNumber;
                String type = shopType;
                microSmartMoHeTouristMapper.addViewDomain(domainId, type);
            }
            JSONObject superMarkerShopDetail = microSmartMoHeTouristMapper.getSuperMarkerShopDetail(shopSerialNumber, currentCoords);
            List<JSONObject> dishInfoList = microSmartMoHeTouristMapper.getDishInfoList(shopSerialNumber);
            superMarkerShopDetail.put("Dish_Info_List", dishInfoList);

            List<JSONObject> merchant_alias_image = microSmartMoHeTouristMapper.getMerchantAliasImage(shopSerialNumber);
            superMarkerShopDetail.put("Merchant_Alias_Image", merchant_alias_image);

            return superMarkerShopDetail;
        }
        if (shopType.equals("美食")) {
            JSONObject viewDomain = microSmartMoHeTouristMapper.getViewDomain(shopSerialNumber, shopType);
            if (null != viewDomain) {
                microSmartMoHeTouristMapper.addViewCntDomain(viewDomain.getString("id"));
            } else {
                String domainId = shopSerialNumber;
                String type = shopType;
                microSmartMoHeTouristMapper.addViewDomain(domainId, type);
            }
            JSONObject deliciousFoodShopDetail = microSmartMoHeTouristMapper.getDeliciousFoodShopDetail(shopSerialNumber, currentCoords);
            List<JSONObject> dishInfoList = microSmartMoHeTouristMapper.getDishInfoList(shopSerialNumber);
            deliciousFoodShopDetail.put("Dish_Info_List", dishInfoList);

            List<JSONObject> merchant_alias_image = microSmartMoHeTouristMapper.getMerchantAliasImage(shopSerialNumber);
            deliciousFoodShopDetail.put("Merchant_Alias_Image", merchant_alias_image);
            return deliciousFoodShopDetail;
        }
        return new JSONObject();
    }

    @Override
    public List<JSONObject> getShopAliasTypeAllList(String shopType) {

        String shopParentCategorySerialNumber = null;
        if (StringUtils.isEmpty(shopType)) {
            shopParentCategorySerialNumber = "MC0000000000011";
        }
        if (shopType.equals("商超")) {
            shopParentCategorySerialNumber = "MC0000000000012";
        }
        if (shopType.equals("美食")) {
            shopParentCategorySerialNumber = "MC0000000000011";
        }
        List<JSONObject> list = microSmartMoHeTouristMapper.getShopAliasTypeAllList(shopParentCategorySerialNumber);
        Set<String> aliasTypeList = new HashSet<>();
        for (JSONObject jsonObject : list) {
            String[] split = jsonObject.getString("Merchant_Alias_Type_SerialNumber").split(",");
            for (String s : split) {
                aliasTypeList.add(s);
            }
        }
        List<JSONObject> result = new ArrayList<>();
        for (String s : aliasTypeList) {
            JSONObject jsonObject = microSmartMoHeTouristMapper.getMerchantAliasTypeDetail(s);
            result.add(jsonObject);
        }
        return result;
    }

    @Override
    public JSONObject getHotFilter(String shopType) {
        JSONObject result = new JSONObject();
        String shopParentCategorySerialNumber = null;
        if (StringUtils.isEmpty(shopType)) {
            shopParentCategorySerialNumber = "MC0000000000011";
        }
        if (shopType.equals("商超")) {
            shopParentCategorySerialNumber = "MC0000000000012";
        }
        if (shopType.equals("美食")) {
            shopParentCategorySerialNumber = "MC0000000000011";
        }
        if (shopType.equals("酒店") || shopType.equals("民宿")) {
            shopParentCategorySerialNumber = "MC0000000000013";
        }


        JSONObject hotFilter = new JSONObject();
        hotFilter.put("title", "热门筛选");
        hotFilter.put("items", microSmartMoHeTouristMapper.getHotFilterList(shopType, shopParentCategorySerialNumber));

        JSONObject scenicSpot = new JSONObject();
        scenicSpot.put("title", "景点");
        scenicSpot.put("items", microSmartMoHeTouristMapper.getHotFilterScenicSpot());

        JSONObject area = new JSONObject();
        area.put("title", "行政区");
        area.put("items", microSmartMoHeTouristMapper.getHotFilterArea(shopParentCategorySerialNumber));

        List<JSONObject> list = new ArrayList<>();
        list.add(hotFilter);
        list.add(scenicSpot);
        list.add(area);

        result.put("contentData", list);
        return result;
    }

    @Override
    public List<JSONObject> getBigSearchHotFilterDataList(int pageNum, int pageSize) {
        List<String> list = Lists.newArrayList();
        list.add("景区");
        list.add("美食");
        list.add("酒店");
        list.add("民宿");
        list.add("商超");
        list.add("农产品");
        List<JSONObject> resultList = new ArrayList<>();
        for (String type : list) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("name", type);
            PageHelper.startPage(pageNum, pageSize);
            if (StringUtils.isEmpty(type)) {
                continue;
            }
            if (type.equals("美食") || type.equals("商超") || type.equals("酒店") || type.equals("民宿")) {
                List<JSONObject> result = microSmartMoHeTouristMapper.getStaticViewDomainByTypeMerchant(type);
                jsonObject.put("list", result);
                resultList.add(jsonObject);
            }
            if (type.equals("农产品")) {
                List<JSONObject> result = microSmartMoHeTouristMapper.getStaticViewDomainByTypeAgriculturalGoods(type);
                jsonObject.put("list", result);
                resultList.add(jsonObject);
            }
            if (type.equals("景区")) {
                List<JSONObject> result = microSmartMoHeTouristMapper.getStaticViewDomainByTypeScenicSpot(type);
                jsonObject.put("list", result);
                resultList.add(jsonObject);
            }


        }
        return resultList;
    }

    @Override
    public List<JSONObject> getAgriculturalGoodsType() {
        return microSmartMoHeTouristMapper.getAgriculturalGoodsType();
    }

    @Override
    public JSONObject getHotelFilterDataList() {
        JSONObject jsonObject = new JSONObject();
        List<JSONObject> list = Lists.newArrayList();

//---------------------------------------------------------------//
        JSONObject hotFilter2 = new JSONObject();
        hotFilter2.put("title", "床型");
        hotFilter2.put("items", microSmartMoHeTouristMapper.getHotelFilterRoomCategory());
        list.add(hotFilter2);
//---------------------------------------------------------------//
        JSONObject hotFilter3 = new JSONObject();
        hotFilter3.put("title", "设施");
        List<JSONObject> hotFilterfacilityList = Lists.newArrayList();

        JSONObject facility1 = new JSONObject();
        facility1.put("name", "免费wifi");
        facility1.put("Is_Wifi", "1");

        JSONObject facility2 = new JSONObject();
        facility2.put("name", "禁烟");
        facility2.put("Is_Partial_Smoking_Ban", "1");


        JSONObject facility3 = new JSONObject();
        facility3.put("name", "免费早餐");
        facility3.put("Is_Breakfast", "1");

        JSONObject facility4 = new JSONObject();
        facility4.put("name", "有窗");
        facility4.put("Window_Type_SerialNumber", "2");


        hotFilterfacilityList.add(facility1);
        hotFilterfacilityList.add(facility2);
        hotFilterfacilityList.add(facility3);
        hotFilterfacilityList.add(facility4);

        hotFilter3.put("items", hotFilterfacilityList);
        list.add(hotFilter3);
//---------------------------------------------------------------//
        JSONObject hotFilter4 = new JSONObject();
        hotFilter4.put("title", "评价");


        List<JSONObject> hotFilterCommentList = Lists.newArrayList();
        JSONObject comment1 = new JSONObject();
        comment1.put("name", "3.5分以上");
        comment1.put("Satisfaction_Count", ">3.5");

        JSONObject comment2 = new JSONObject();
        comment2.put("name", "3.8分以上");
        comment2.put("Satisfaction_Count", ">3.8");

        JSONObject comment3 = new JSONObject();
        comment3.put("name", "干净卫生");
        comment3.put("Comment_Content", "干净卫生");

        JSONObject comment4 = new JSONObject();
        comment4.put("name", "隔音好");
        comment4.put("Comment_Content", "隔音好");


        hotFilterCommentList.add(comment1);
        hotFilterCommentList.add(comment2);
        hotFilterCommentList.add(comment3);
        hotFilterCommentList.add(comment4);

        hotFilter4.put("items", hotFilterCommentList);

        list.add(hotFilter4);
//---------------------------------------------------------------//
        JSONObject hotFilter5 = new JSONObject();
        hotFilter5.put("title", "等级");
        hotFilter5.put("items", microSmartMoHeTouristMapper.getHotelFilterHotelAliasType());
        list.add(hotFilter5);

//---------------------------------------------------------------//
        jsonObject.put("contentData1", list);
        return jsonObject;
        //{
        //    "contentData1": [
        //        {
        //            "title": "床型",
        //            "items": [
        //                {
        //                    "Room_Category": "大床房",
        //                    "Room_Category_SerialNumber": "RC0000000000001"
        //                },
        //                {
        //                    "Room_Category": "电竞房",
        //                    "Room_Category_SerialNumber": "RC0000000000002"
        //                }
        //            ]
        //        },
        //        {
        //            "title": "设施",
        //            "items": [
        //                {
        //                    "Is_Wifi": "1",
        //                    "Name": "免费wifi"
        //                },
        //                {
        //                    "Is_Partial_Smoking_Ban": "1",
        //                    "Name": "禁烟"
        //                },
        //                {
        //                    "Is_Breakfast": "1",
        //                    "Name": "有早餐"
        //                },
        //                {
        //                    "Window_Type_SerialNumber": "2",
        //                    "Name": "有窗"
        //                },
        //                {
        //                    "Window_Type_SerialNumber": "3",
        //                    "Name": "落地窗"
        //                }
        //            ]
        //        },
        //        {
        //            "title": "评价",
        //            "items": [
        //                {
        //                    "Satisfaction_Count": ">3.5",
        //                    "Name": "3.5分以上"
        //                },
        //                {
        //                    "Satisfaction_Count": ">3.8",
        //                    "Name": "3.8分以上"
        //                },
        //                {
        //                    "Comment_Content": "干净卫生",
        //                    "Name": "干净卫生"
        //                },
        //                {
        //                    "Comment_Content": "安静隔音好",
        //                    "Name": "安静隔音好"
        //                }
        //            ]
        //        },
        //        {
        //            "title": "等级",
        //            "items": [
        //                {
        //                    "Name": "经济型",
        //                    "Merchant_Alias_Type_SerialNumber": "MAT000000000007"
        //                },
        //                {
        //                    "Name": "舒适型",
        //                    "Merchant_Alias_Type_SerialNumber": "MAT000000000008"
        //                },
        //                {
        //                    "Name": "豪华型",
        //                    "Merchant_Alias_Type_SerialNumber": "MAT000000000009"
        //                }
        //            ]
        //        }
        //    ]
        //}
    }

    @Override
    public List<JSONObject> getAllListSearch(String search) {
        List<String> list = Lists.newArrayList();
        list.add("景区");
        list.add("美食");
        list.add("商超");
        list.add("酒店民宿");
        list.add("农产品");
        List<JSONObject> resultList = new ArrayList<>();
        list.forEach(
                type -> {
                    String shopParentCategorySerialNumber = "";
                    if (type.equals("商超")) {
                        shopParentCategorySerialNumber = "MC0000000000012";
                    }
                    if (type.equals("美食")) {
                        shopParentCategorySerialNumber = "MC0000000000011";
                    }
                    if (type.equals("酒店民宿")) {
                        shopParentCategorySerialNumber = "MC0000000000013";
                    }
                    if (type.equals("美食") || type.equals("商超") || type.equals("酒店民宿")) {
                        List<JSONObject> result = microSmartMoHeTouristMapper.getShopSearch(search, "", "",
                                "", "", "",
                                "", null, "",
                                "", "", shopParentCategorySerialNumber, "");

                        result.forEach(jsonObject -> {
                            JSONObject jsonObject1 = new JSONObject();
                            jsonObject1.put("type", type);
                            jsonObject1.put("name", jsonObject.get("Merchant_Alias"));
                            jsonObject1.put("id", jsonObject.get("Shop_SerialNumber"));
                            jsonObject1.put("image", jsonObject.get("Main_Image"));
                            resultList.add(jsonObject1);
                        });

                    }
                    if (type.equals("农产品")) {
                        List<JSONObject> result = microSmartMoHeTouristMapper.getAgriculturalGoodsSearch(null, search);
                        result.forEach(jsonObject -> {
                            JSONObject jsonObject1 = new JSONObject();
                            jsonObject1.put("type", type);
                            jsonObject1.put("name", jsonObject.get("Goods_Name"));
                            jsonObject1.put("id", jsonObject.get("Agricultural_Supplies_Store_Goods_SerialNumber"));
                            jsonObject1.put("image", jsonObject.get("Picture_URL"));
                            resultList.add(jsonObject1);
                        });
                    }
                    if (type.equals("景区")) {
                        List<JSONObject> result = microSmartMoHeTouristMapper.getScenicSpotList("", "", search);
                        result.forEach(jsonObject -> {
                            JSONObject jsonObject1 = new JSONObject();
                            jsonObject1.put("type", type);
                            jsonObject1.put("name", jsonObject.get("Scenic_Spot_Name"));
                            jsonObject1.put("id", jsonObject.get("Scenic_Spot_SerialNumber"));
                            jsonObject1.put("image", jsonObject.get("Picture_URL"));
                            resultList.add(jsonObject1);
                        });
                    }

                }
        );
        return resultList;
    }

    @Override
    public JSONObject getHotelApartmentShopDetailDishInfoPage(String shopSerialNumber, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<JSONObject> dishInfoPage = microSmartMoHeTouristMapper.getHotelApartmentShopDetailDishInfoPage(shopSerialNumber);
        PageInfo<JSONObject> pageInfo = new PageInfo<>(dishInfoPage);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list", pageInfo.getList());
        jsonObject.put("total", pageInfo.getTotal());
        return jsonObject;
    }

    @Override
    public JSONObject getMicroAccountInformation(String openId) {
        JSONObject microAccountInformation = microSmartMoHeTouristMapper.getMicroAccountInformation(openId);
        if(ObjectUtils.isEmpty(microAccountInformation)){
            return new JSONObject();
        }
        String birthday = microAccountInformation.getString("Birthday");
        if(!StringUtils.isEmpty(birthday)){
            //根据当前生日计算几岁了
            //如果生日是1月1日 则默认0岁
            if(birthday.substring(4,6).equals("01") && birthday.substring(6,8).equals("01")){
                microAccountInformation.put("Age",0);
            }
            //如果生日不是1月1日 则根据当前时间计算几岁了
            if(!(birthday.substring(4,6).equals("01") && birthday.substring(6,8).equals("01"))){
                microAccountInformation.put("Age", Integer.parseInt(DateFormatUtils.format(new Date(),"yyyy"))-Integer.parseInt(birthday.substring(0,4)));
            }

        }else{
            //如果没有生日 则默认0岁
            microAccountInformation.put("Age",0);
        }
        return microAccountInformation;
    }

    @Override
    @Transactional
    public int updateMemberAccountInfo(String openld, String unionId, String contactPhone, String memberNike, String image, String sex, String birthday, String appId) {
        return microSmartMoHeTouristMapper.updateMemberAccountInfo(openld,unionId,contactPhone,memberNike,image,sex,birthday,appId);
    }

    @Override
    public JSONObject getParkingList(String currentCoords, String search, String km, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<JSONObject> parkingList = microSmartMoHeTouristMapper.getParkingList("BPT000000010026",search,km,currentCoords);
        PageInfo<JSONObject> pageInfo = new PageInfo<>(parkingList);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list", pageInfo.getList());
        jsonObject.put("total", pageInfo.getTotal());
        return jsonObject;
    }

    @Override
    public JSONObject getShopBlackWhiteList(String commentType, String rankType, String shopType, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        String shopParentCategorySerialNumber = null;
        if (StringUtils.isEmpty(shopType)) {
            shopParentCategorySerialNumber = null;
        } else {
            if (shopType.equals("商超")) {
                shopParentCategorySerialNumber = "MC0000000000012";
            }
            if (shopType.equals("美食")) {
                shopParentCategorySerialNumber = "MC0000000000011";
            }
            if (shopType.equals("酒店民宿")) {
                shopParentCategorySerialNumber = "MC0000000000013";
            }
        }
        List<JSONObject> list = microSmartMoHeTouristMapper.getShopBlackWhiteList(commentType, rankType, shopParentCategorySerialNumber);
        for (int i = 0; i < list.size(); i++) {
            JSONObject jsonObject = list.get(i);
            jsonObject.put("id",i+1);
            if(jsonObject.containsKey("tags")) {
                String[] tags = jsonObject.getString("tags").split(",");
                List<String> aliasList = Lists.newArrayList();
                for (String tag : tags) {
                    aliasList.add(tag);
                }
                jsonObject.put("tags",aliasList);
            }
            if(jsonObject.containsKey("Merchant_Alias_Type_SerialNumber")) {
                String[] aliasTypeSerialNumber = jsonObject.getString("Merchant_Alias_Type_SerialNumber").split(",");
                List<String> aliasList = Lists.newArrayList();

                for (Object merchantAliasTypeSerialNumber1 : aliasTypeSerialNumber) {
                    JSONObject merchantAliasTypeSerialNumberDetail = microSmartMoHeTouristMapper.getMerchantAliasTypeSerialNumberDetail(merchantAliasTypeSerialNumber1.toString());
                    if (null != merchantAliasTypeSerialNumberDetail) {
                        aliasList.add(merchantAliasTypeSerialNumberDetail.getString("Merchant_Alias_Type"));
                    }
                }
                jsonObject.put("tags",aliasList);
            }


        }
        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
        JSONObject result = new JSONObject();
        result.put("list", pageInfo.getList());
        result.put("total", pageInfo.getTotal());
        return result;
    }

    @Override
    public int getMyComplaintsDraftCnt(String phone) {
        return microSmartMoHeTouristMapper.getMyComplaintsDraftCnt(phone);
    }

    private void execFormatSubTitle(List<NewsVo> newsVoList) {
        newsVoList.forEach(newsVo -> {
            String newsSubTitle = newsVo.getNewsSubTitle();
            if (!StringUtils.isEmpty(newsSubTitle)) {
                Document doc = Jsoup.parse(newsSubTitle);

                // 查找第一个<p>标签
                Elements paragraphs = doc.select("p");
                if (paragraphs.size() > 0) {
                    Element firstParagraph = paragraphs.first(); // 获取第一个<p>标签
                    String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                    if (content.length() > 70) {
                        content = content.substring(0, 67) + "...";
                    }
                    newsVo.setNewsSubTitle(content);
                    return;
                } else {
                    Elements h1 = doc.select("h1");
                    Elements h2 = doc.select("h2");
                    Elements h3 = doc.select("h3");
                    Elements h4 = doc.select("h4");
                    Elements h5 = doc.select("h5");
                    Elements ul = doc.select("ul");
                    Elements ol = doc.select("ol");
                    Elements li = doc.select("li");
                    Elements div = doc.select("div");
                    Elements span = doc.select("span");
                    Elements strong = doc.select("strong");
                    if (h1.size() > 0) {
                        Element firstParagraph = h1.first(); // 获取第一个<h1>标签
                        String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                        if (content.length() > 70) {
                            content = content.substring(0, 67) + "...";
                        }
                        newsVo.setNewsSubTitle(content);
                        return;
                    }
                    if (h2.size() > 0) {
                        Element firstParagraph = h2.first(); // 获取第一个<h2>标签
                        String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                        if (content.length() > 70) {
                            content = content.substring(0, 67) + "...";
                        }
                        newsVo.setNewsSubTitle(content);
                        return;
                    }
                    if (h3.size() > 0) {
                        Element firstParagraph = h3.first(); // 获取第一个<h1>标签
                        String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                        if (content.length() > 70) {
                            content = content.substring(0, 67) + "...";
                        }
                        newsVo.setNewsSubTitle(content);
                        return;
                    }
                    if (h4.size() > 0) {
                        Element firstParagraph = h4.first(); // 获取第一个<h1>标签
                        String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                        if (content.length() > 70) {
                            content = content.substring(0, 67) + "...";
                        }
                        newsVo.setNewsSubTitle(content);
                        return;
                    }
                    if (h5.size() > 0) {
                        Element firstParagraph = h5.first(); // 获取第一个<h1>标签
                        String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                        if (content.length() > 70) {
                            content = content.substring(0, 67) + "...";
                        }
                        newsVo.setNewsSubTitle(content);
                        return;
                    } if (ul.size() > 0) {
                        Element firstParagraph = ul.first(); // 获取第一个<h1>标签
                        String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                        if (content.length() > 70) {
                            content = content.substring(0, 67) + "...";
                        }
                        newsVo.setNewsSubTitle(content);
                        return;
                    } if (ol.size() > 0) {
                        Element firstParagraph = ol.first(); // 获取第一个<h1>标签
                        String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                        if (content.length() > 70) {
                            content = content.substring(0, 67) + "...";
                        }
                        newsVo.setNewsSubTitle(content);
                        return;
                    } if (div.size() > 0) {
                        Element firstParagraph = div.first(); // 获取第一个<h1>标签
                        String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                        if (content.length() > 70) {
                            content = content.substring(0, 67) + "...";
                        }
                        newsVo.setNewsSubTitle(content);
                        return;
                    } if (span.size() > 0) {
                        Element firstParagraph = span.first(); // 获取第一个<h1>标签
                        String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                        if (content.length() > 70) {
                            content = content.substring(0, 67) + "...";
                        }
                        newsVo.setNewsSubTitle(content);
                        return;
                    } if (strong.size() > 0) {
                        Element firstParagraph = strong.first(); // 获取第一个<h1>标签
                        String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                        if (content.length() > 70) {
                            content = content.substring(0, 67) + "...";
                        }
                        newsVo.setNewsSubTitle(content);
                        return;
                    } if (li.size() > 0) {
                        Element firstParagraph = li.first(); // 获取第一个<h1>标签
                        String content = firstParagraph.text(); // 获取标签的内容 如果超长 则处理为...
                        if (content.length() > 70) {
                            content = content.substring(0, 67) + "...";
                        }
                        newsVo.setNewsSubTitle(content);
                        return;
                    }
                }
            }
        });
    }
}
